package com.twittex.view
{
	import com.twittex.TwittexFacade;
	import com.twittex.view.components.NavigationScreen;
	
	import flash.events.Event;
	
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class NavigationScreenMediator extends Mediator
	{
		public static const NAME:String = "NavigationScreenMediator";


		public function NavigationScreenMediator(viewComponent:NavigationScreen) {
			super(NAME, viewComponent);
			
			navigationScreen.addEventListener(NavigationScreen.HOME, onNavigation);
			navigationScreen.addEventListener(NavigationScreen.REPLIES, onNavigation);
			navigationScreen.addEventListener(NavigationScreen.MESSAGES, onNavigation);
			navigationScreen.addEventListener(NavigationScreen.FAVORITES, onNavigation);
			navigationScreen.addEventListener(NavigationScreen.EVERYONE, onNavigation);
		}
		
		override public function onRegister():void {
			sendNotification(TwittexFacade.VIEW_FRIENDS_SCREEN);
		}
		
		protected function get navigationScreen():NavigationScreen {
			return viewComponent as NavigationScreen;
		}
		
		private function onNavigation(event:Event):void {
			switch(event.type) {
				case NavigationScreen.HOME:
					sendNotification(TwittexFacade.VIEW_FRIENDS_SCREEN);
					break;
				case NavigationScreen.REPLIES:
					sendNotification(TwittexFacade.VIEW_REPLIES_SCREEN);
					break;
			}
		}
		
	}
}